<script language='JavaScript' type='text/javascript'>
function showDiv(divId)
{
	if (document.getElementById(divId).style.display=="none")
	{
	  document.getElementById(divId).style.display='block';
	}
	else
	{
	  document.getElementById(divId).style.display='none';
	}

}
</script>

<div id="maincontent">
<%= render :partial => "shared_common_files/data_area_help_bar" %>

  <% for name in [:simplemsg] %>
  	<% if flash[name] %>
      <%= "<div class='message-justmsg'> #{flash[name]} </div>" %>
  	<% end %>
  <% end %>

  <% for name in [:notice, :warning, :message] %>
  	<% if flash[name] %>
      <%= "<div class='message-fatal'> #{flash[name]} </div>" %>
    <% end %>
  <% end %>



<h2>Mashup Create/Update</h2>					
		
		
					
<%= start_form_tag({:action => ''},{:class => 'appform'}, {:method=> 'post'}) %>
	<fieldset>
		
		<h3> Your web service details are as follows</h3>
		
		<% if (params['node'] == "salesforce") %>
		
<%if(@test_connection!=nil)%>

	<div class='message-justmsg'> 
		<font color="black"><%=@test_connection.connection_message%> 
		<br/>
		
		<a href="javascript:showDiv('login_div')">Show connection details</a>
  		
  		<div  id="login_div" style="display: none;">
		
		Session Id: <%=@test_connection.response_object.result.sessionId[0,10]%>.... 
		<br/>
		
		Server URL: <%=@test_connection.response_object.result.serverUrl%> 
		<br/>
		
		User Id: <%=@test_connection.response_object.result.userId%> 
		<br/>
  		
  		</div>
  		</font>
	</div>
<%end%>
			<%=error_messages_for("mashup_node")%>
		<!--
			<label for="name"><b><span class="req"></span>Mashup Name :</b> <%=@mashup_node.name%> <br />
			
			</label>
		-->
		
			<label for="name"><b><span class="req"></span>User Name :</b> <%=@mashup_node.username%> <br />
			</label>
		
			<label for="name"><b><span class="req"></span>Password :</b><%=AjubyTools.mask_string(@mashup_node.password, "*")%><br/>
			</label>
		
			<label for="name"><b><span class="req"></span>WSDL URL :</b><%=@mashup_node.wsdl_url%><br />
			</label>

			<label for="name"><b><span class="req"></span>Debug Flag :</b/><%=@mashup_node.debug_soap%><br />
			</label>  

			<label for="name"><b><span class="req"></span>Default Records Size :</b><%=@mashup_node.records_size%><br />
			</label>
		
		
     		<input type="hidden" name="node" value="<%=params['node']%>">
     		<input type="hidden" name="op" value="save">
    		
    		<div class="f-submit-wrap">
		
				<%if(canRequestLink("integration","edit"))%>
					<a href="/integration/edit?node=<%=@mashup_node.name%>"><!-- input type="button" value="Edit"/ --><img src='/themes/odotclassic/images/btn_edit.png' alt="Edit"></a>
				<%end%>
		
				<%if(canRequestLink("integration","test_connection"))%>
					<a href="/integration/test_connection?op=login&node=<%=params['node']%>"><!-- input type="button" value="Test Connection"/ --><img src='/themes/odotclassic/images/btn_testconn.png' alt="Test Connection"></a>
				<%end%>

				<%if(canRequestLink("integration","browse_objects"))%>
					<a href="/integration/browse_objects?node=<%=@mashup_node.name%>" type="button" /><!-- input type="button" value="Browse Objects"/ --><img src='/themes/odotclassic/images/btn_brobjects.png' alt="Browse Objects"></a>
				<%end%>
	  		</div>
	  
	  	<%elsif (params['node'] == "sugarcrm") %>
	
<%if(@test_connection!=nil)%>

	<div class='message-justmsg'> 
		<font color="black"><%=@test_connection.connection_message%> 
		<br/>
		
		<a href="javascript:showDiv('login_div')">Show connection details</a>
  		
  		<div  id="login_div" style="display: none;">
		
		Session Id: <%=@test_connection.response_object.id[0,10]%>.... 
		<br/>
	
		<% service = AjubySoapBox.connect(@mashup_node.wsdl_url,@mashup_node.debug_soap)
						@server_version = service.get_server_version
						@user_id = service.get_user_id(@test_connection.response_object.id)%>
						
		Server Version: <%=@server_version%>	
		<br/>
		
		User Id: <%=@user_id%>
	
  		</div>
  		</font>
	</div>
<%end%>	
			<%=error_messages_for("mashup_node")%>
		
			<label for="name"><b><span class="req"></span>User Name :</b> <%=@mashup_node.username%> <br />
			</label>
		
			<label for="name"><b><span class="req"></span>Password :</b><%=AjubyTools.mask_string(@mashup_node.password, "*")%><br/>
			</label>
		
			<label for="name"><b><span class="req"></span>WSDL URL :</b><%=@mashup_node.wsdl_url%><br />
			</label>

			<label for="name"><b><span class="req"></span>Debug Flag :</b/><%=@mashup_node.debug_soap%><br />
			</label>  

			<label for="name"><b><span class="req"></span>Default Records Size :</b><%=@mashup_node.records_size%><br />
			</label>
		
		
     		<input type="hidden" name="node" value="<%=params['node']%>">
     		<input type="hidden" name="op" value="save">
    		
    		<div class="f-submit-wrap">
		
				<%if(canRequestLink("integration","edit"))%>
					<a href="/integration/edit?node=<%=@mashup_node.name%>"><!-- input type="button" value="Edit"/ --><img src='/themes/odotclassic/images/btn_edit.png' alt="Edit"></a>
				<%end%>
		
				<%if(canRequestLink("integration","test_connection"))%>
					<a href="/integration/test_connection?op=login&node=<%=params['node']%>"><!-- input type="button" value="Test Connection"/ --><img src='/themes/odotclassic/images/btn_testconn.png' alt="Test Connection"></a>
				<%end%>

				<%if(canRequestLink("integration","browse_objects"))%>
					<a href="/integration/browse_objects?node=<%=@mashup_node.name%>" type="button" /><!-- input type="button" value="Browse Objects"/ --><img src='/themes/odotclassic/images/btn_brobjects.png' alt="Browse Objects"></a>
				<%end%>
	  		</div>
	  	
	 	<%elsif(params['node'] == "amazonws")%>
		
			<label for="name"><b><span class="req"></span>Access Key Id :</b> <%=@mashup_node.custom_field1%> <br />
			</label>
		
			<label for="name"><b><span class="req"></span>Secret Access Key :</b><%=AjubyTools.mask_string(@mashup_node.custom_field2, "*")%><br/>
			</label>
			
			<input type="hidden" name="node" value="<%=params['node']%>">
     		<input type="hidden" name="op" value="save">
     		
     		<div class="f-submit-wrap">
			
				<%if(canRequestLink("integration","edit"))%>
					<a href="/integration/edit?node=<%=@mashup_node.name%>"><!-- input type="button" value="Edit"/ --><img src='/themes/odotclassic/images/btn_edit.png' alt="Edit"></a>
				<%end%>
		
				<%if(canRequestLink("integration","gotobackup"))%>
					<a href="/dbbackup/backup"><!-- input type="button" value="Go to backup"/ --><img src='/themes/odotclassic/images/btn_gtbackup.png' alt="Backup"></a>
				<%end%>
	  		</div>
	  		
	  	<%elsif(params['node'] == "basecamp")%>
	  	
	  		<label for="name"><b><span class="req"></span>User Name :</b> <%=@mashup_node.username%> <br />
			</label>
		
			<label for="name"><b><span class="req"></span>Password :</b><%=AjubyTools.mask_string(@mashup_node.password, "*")%><br/>
			</label>
		
			<label for="name"><b><span class="req"></span>URL :</b><%=@mashup_node.wsdl_url%><br />
			</label>
			
			<input type="hidden" name="node" value="<%=params['node']%>">
     		<input type="hidden" name="op" value="save">
     		
     		<div class="f-submit-wrap">
			
				<%if(canRequestLink("integration","edit"))%>
					<a href="/integration/edit?node=<%=@mashup_node.name%>"><!-- input type="button" value="Edit"/ --><img src='/themes/odotclassic/images/btn_edit.png' alt="Edit"></a>
				<%end%>
		
				<%if(canRequestLink("integration","browse_projects"))%>
					<a href="/integration/browse_projects?node=<%=@mashup_node.name%>"><!-- input type="button" value="Browse Projects"/ --><img src='/themes/odotclassic/images/btn_brproj.png' alt="Browse Projects"></a>
				<%end%>
	  		</div>
	  	
	  	
		<%end%> 	
	  	
	</fieldset>
<%= end_form_tag %>
 	
</div>